package com.mrbeard.test;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;

import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;


public class testHql {

//	@Test
//	public void Tes() {
//		// 容器
//		ApplicationContext ac2 = new ClassPathXmlApplicationContext("bean-service.xml");
//
//		// 从容器中获取bean
//		StudentService service = (StudentService) ac2.getBean("studentService");
//
//		Student s = (Student) service.findByName("张三");
//
//		System.out.println(s);
//	}

	
	  
    /** 
     * @param args 
     */  
    public static void main(String[] args) {  
        // TODO Auto-generated method stub  
    	testHql t6=new testHql();  
        String htmls= t6.getPageSource("http://www.btbuluo.com/s/%E4%BD%A0%E5%A5%BD.html","UTF-8");  
        System.out.println(htmls);  
    }  
      
    public String getPageSource(String pageUrl,String encoding) {    
        StringBuffer sb = new StringBuffer();    
        try {    
            //构建一URL对象    
            URL url = new URL(pageUrl);    
            //使用openStream得到一输入流并由此构造一个BufferedReader对象    
            BufferedReader in = new BufferedReader(new InputStreamReader(url    
                    .openStream(), encoding));    
            String line;    
            //读取www资源    
            while ((line = in.readLine()) != null) {    
                sb.append(line);    
                sb.append("\n");  
            }    
            in.close();    
        } catch (Exception ex) {    
            System.err.println(ex);    
        }    
        return sb.toString();    
    }   
  
	
	
}
